/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sree.tali.buscomp;

import com.sree.tali.dao.homepage.impl.QuestionDao;
import com.sree.tali.dao.homepage.impl.QuestionDaoImpl;
import com.sree.tali.hibernate.pojo.QuestionPojo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.hibernate.Session;

/**
 *
 * @author LENOVO
 */
public class QuestionBusCompImpl implements QuestionBusComp {

    @Override
    public void addBit(QuestionPojo questionpojo, Session session) {
        QuestionDao questiondao = new QuestionDaoImpl();
        questiondao.addBit(questionpojo, session);
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<QuestionPojo> showbits(String category, Session session) {
        List<QuestionPojo> questionpojolist = new ArrayList<QuestionPojo>();
        QuestionDao questiondao = new QuestionDaoImpl();
        questionpojolist = questiondao.showbits(category, session);
        setbits(questionpojolist);
        return questionpojolist;
    }
     public void  setbits( List<QuestionPojo>  questionpojolist)
     {
         for(QuestionPojo questionpojo :questionpojolist )
         {
            // System.out.println(questionpojo.getOptions().split(","));
             questionpojo.setAnswers(Arrays.asList(questionpojo.getOptions().split(",")));
         }

    }

    @Override
    public void updateBit(int id, Session session) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
